Skip to content

[Renesas RX72N CCRX] Move flash functions to RAM for flash operation#689

Open
miyazakh wants to merge 2 commits intowolfSSL:masterfrom
miyazakh:ram_function_ccrx
Open

[Renesas RX72N CCRX] Move flash functions to RAM for flash operation#689
miyazakh wants to merge 2 commits intowolfSSL:masterfrom
miyazakh:ram_function_ccrx

Conversation

@miyazakh
Copy link
Contributor

@miyazakh miyazakh commented Feb 19, 2026

Move flash functions to RAM for flash operation
Changed hal_flash_write() to align address to 128-byte boundary
Remove standard library use as much as possible

@miyazakh miyazakh self-assigned this Feb 19, 2026
@miyazakh miyazakh requested review from dgarske and kojiws February 19, 2026 07:30
Copy link

@kojiws kojiws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every part is good for me.
I have just one confirmation below.

@miyazakh miyazakh assigned wolfSSL-Bot and unassigned miyazakh Feb 19, 2026
Copy link

@kojiws kojiws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements support for executing flash write/erase operations from RAM on the Renesas RX72N platform using the CCRX compiler. The changes enable proper flash programming by moving critical flash operation functions to RAM execution, aligning flash writes to 128-byte boundaries as required by the hardware, and reducing dependency on standard library functions.

Changes:

  • Added CCRX pragma directives to place flash-related functions in RAM (FRAM section) with automatic ROM-to-RAM copying at initialization
  • Modified hal_flash_write() to handle 128-byte aligned block writes with read-modify-write logic for partial blocks
  • Added flash error checking with new flash_err_t enum and flash_check_error() function
  • Removed standard library dependencies for CCRX builds where possible

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/update_flash.c Added CCRX pragma section directives to place update functions in FRAM section
src/string.c Removed CCRX exclusions and added FRAM pragma for memcpy function (with missing closing directive)
src/libwolfboot.c Added FRAM section pragma directives for partition/trailer management functions
src/boot_renesas.c Added debug verify_flash_write function (unused) and debug printf
hal/renesas-rx.h Added flash_err_t enum for flash error codes
hal/renesas-rx.c Implemented copyfuncs() for ROM-to-RAM copy, flash_check_error(), and rewrote hal_flash_write() for 128-byte alignment; removed unused variables
IDE configuration files Updated linker configuration to map PFRAM to RPFRAM sections, added compiler options, and configured standard library usage
app_RenesasRX01 files Added debug functions, updated partition display logic, and linked string.c

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +58 to +67
static void verify_flash_write(uint32_t addr, int len)
{
uint8_t *p = (uint8_t *)addr;
int i;
printf("verify addr=0x%08x: ", addr);
for (i = 0; i < len && i < 8; i++) {
printf("%02x ", p[i]);
}
printf("\n");
}
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is defined but never called in the codebase. If it's intended for debugging purposes, consider either removing it or using it in appropriate places. If it's meant to be kept for future use, add a comment explaining its purpose.

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +99
#ifdef WOLFBOOT_DEBUG_PARTION
static void verify_flash_write(uint32_t addr, int len)
{
uint8_t *p = (uint8_t *)addr;
int i;
printf("verify addr=0x%08x: ", addr);
for (i = 0; i < len && i < 8; i++) {
printf("%02x ", p[i]);
}
printf("\n");
}
#endif
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is defined but never called in the codebase. If it's intended for debugging purposes, consider either removing it or using it in appropriate places. If it's meant to be kept for future use, add a comment explaining its purpose.

Copilot uses AI. Check for mistakes.
@@ -286,7 +284,7 @@ void RAMFUNCTION *memcpy(void *dst, const void *src, size_t n)
}
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pragma section FRAM directive is opened on line 258 but never closed. This will cause all subsequent code in the file to be placed in the FRAM section, which is likely unintended. A closing #pragma section directive should be added after the memcpy function definition, similar to how it's done in other files in this PR.

Suggested change
}
}
#ifdef __CCRX__
#pragma section
#endif

Copilot uses AI. Check for mistakes.

#ifdef __CCRX__
/* copy RAM functions from ROM to RAM */
static void copyfuncs(void)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this could still just use memcpy or be a version that isn't a "RAMFUNCTION" and pass in the normal dst, src, size?

int ret, i, chunk;
uint8_t codeblock[FLASH_FACI_CODE_BLOCK_SZ];
int i;
uint8_t codeblock[FLASH_FACI_CODE_BLOCK_SZ] = {0};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= {0} isn't portable. If you need it use memset.

block_base = addr & ~(FLASH_FACI_CODE_BLOCK_SZ - 1);
offset = addr - block_base;

XMEMCPY(codeblock, (uint8_t*)block_base, FLASH_FACI_CODE_BLOCK_SZ);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be using memcpy because it uses wolfboot's string.c. Are you sure you can't build the RX72 CCRX without the stdlib??

Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments